<template>
    <div>
        <a-modal
        :visible="processingConditionsVisible"
        :confirm-loading="confirmLoading"
        @ok="handleOk"
        @cancel="handleCancel"
        :closable="submitModalData.closable"
        :maskClosable="submitModalData.maskClosable"
        width="calc(100% - 100px)"
        class="processing-conditions-option-modal"
        :centered="true"
        >
        <!-- <slot name="querButton" :data="data" ></slot> -->
            <!-- 头部 -->
            <template slot="title">
                <div style="width: 100%;display: flex;font-family: KaiTi !important;color: #ffffff !important;">
                    <span  class="modal-header-left-title" style="color: #fff !important;">{{ submitModalData.headerLeftTitle }}</span>
                    <span class="modal-header-conter-title" style="font-family: KaiTi !important;color: #ffffff !important;">{{submitModalData.headerCenterTitle}}</span>
                </div>
            </template>
            <a-spin :tip="spinTip" :spinning="spinning">
                <div class="processing-conditions-content" :key="processingConditionsKey">
                    <div class="left-content"  ref="containerBox">
                        <div :style="{marginRight: rapidPositioning?'145px':'0'}">
                            <a-collapse v-model:activeKey="submitActiveKey" >
                                <a-collapse-panel id="processingConditions01" key="1" header="办理记录" >
                                    <commpVxeTable
                                        ref="headmanVxeTable"
                                        :key="internalOpinionsKey"
                                        :config="internalOpinionsConfig" 
                                        :columns="internalOpinionsColumnsVxe" 
                                        :formItem="[]"
                                        :adaptiveHeight="true"
                                    >
                                        <template v-slot:fblr_default="{row}">
                                            <span style="padding-right: 21;" v-if="row.fblr && row.fblr.length == 2">
                                                <span v-for="(trem,tI) in row.fblr.split('')" :key="tI" >
                                                    {{trem}} 
                                                    <span v-if="tI+1 !== row.fblr.split('').length">&nbsp;&nbsp;</span>
                                                </span>
                                            </span>
                                            <span style="padding-right: 21;" v-else>{{ row.fblr }}</span>
                                        </template>
                                    </commpVxeTable>
                                </a-collapse-panel>
                                <a-collapse-panel id="processingConditions02" key="2" header="办理意见" v-if="submitModalData.isBlyj">
                                    <a-form ref="form" :form="form" >
                                        <a-form-item v-if="submitModalData.isNbbl">
                                            <div>
                                                <a-button class="blue-btn" @click="selectInternalTransfer" type="primary">选择办理人</a-button>
                                            </div>
                                            <span>已选办理人：</span>
                                            <a-textarea 
                                                :readOnly="true"
                                                v-model:value="formState.internalTransferName"
                                                v-decorator="['internalTransferName',{ initialValue:formState.internalTransferName, rules: rules.internalTransferName}]"
                                                placeholder="已选办理人"
                                                :autosize="{ minRows: 2, maxRows: 10000 }"
                                            ></a-textarea>
                                        </a-form-item>
                                        <a-form-item v-if="submitModalData.isBlr">
                                            <span>办理人：</span>
                                            <a-select
                                                mode="multiple"
                                                placeholder="请选择办理人"
                                                style="width: 200px"
                                                v-decorator="['dbrid',{ initialValue:formState.dbrid, rules: rules.dbrid}]"
                                                >
                                                <a-select-option v-for="(item,index) in submitModalData.nextNodeDbrList" :key="index" :value="item.dbrid?item.dbrid:item.value">
                                                    {{ item.dbr?item.dbr:item.label }}
                                                </a-select-option>
                                            </a-select>
                                            <!-- <span v-if="submitModalData.headerCenterTitle && submitModalData.headerCenterTitle.indexOf('综合评定') !== -1" class="tj-blr-tips-box" >提示：请选择2个办理人</span> -->
                                        </a-form-item>
                                        <a-form-item v-if="!submitModalData.isBlr && !submitModalData.NoViewBlr && submitModalData.nextNode !== '办结'">
                                            <span>办理人：</span>
                                            <span v-for="(item,index) in submitModalData.nextNodeDbrList" :key="index" :value="item.dbrid?item.dbrid:item.value">{{ item.dbr?item.dbr:item.label }}{{ index+1 == submitModalData.nextNodeDbrList.length?'':'，' }}</span>
                                        </a-form-item>
                                        <a-form-item v-if="submitModalData.isDepJbr">
                                            <span>部门经办人：</span>
                                            <!-- :options="depHandledList" -->
                                            <!-- <a-select
                                                mode="multiple"
                                                placeholder="请选择办理人"
                                                style="width: 200px"
                                                v-decorator="['dbrid',{ initialValue:formState.dbrid, rules: rules.dbrid}]"
                                                >
                                                <a-select-option v-for="(item,index) in depHandledList" :key="index" :value="item.dbrid?item.dbrid:item.value">
                                                    {{ item.dbr?item.dbr:item.label }}
                                                </a-select-option>
                                            </a-select> -->
                                            <a-select
                                                placeholder="请选择部门经办人"
                                                style="width: 200px"
                                                v-model:value="formState.fxzspysrid"
                                                @change="handleChange"
                                            >
                                                <a-select-option v-for="i in depHandledList" :key="i.id" :value="i.value">
                                                    {{ i.label}}
                                                </a-select-option>
                                            </a-select>
                                            <!-- v-decorator="['fxzspysrid',{ initialValue:formState.fxzspysrid, rules: rules.fxzspysrid}]" -->
                                        </a-form-item>
                                        <a-form-item v-if="submitModalData.isThhj">
                                            <span>退回环节：</span>
                                            <a-select
                                                :options="fthyjOptions"
                                                placeholder="请选择退回环节"
                                                style="width: 130px"
                                                v-model:value="formState.shjid"
                                                v-decorator="['shjid',{ initialValue:formState.shjid, rules: rules.shjid}]"
                                                >
                                            </a-select>
                                        </a-form-item>
                                        <a-form-item v-if="submitModalData.isYwbmjbr && (submitModalData.headerCenterTitle && submitModalData.headerCenterTitle.indexOf('移送确认') !== -1)">
                                            <a-spin tip="正在加载中..." :spinning="depManagerSpinning">
                                                <span>业务部门经办人：</span>
                                                <a-select
                                                    placeholder="请选择业务部门经办人"
                                                    style="width: 200px"
                                                    v-decorator="['jbrid',{ initialValue:formState.jbrid, rules: rules.jbrid}]"
                                                >
                                                    <a-select-option v-for="(item,index) in departmentManagerList" :key="index" :value="item.id">
                                                        {{ item.deptName+'/'+item.name }}
                                                    </a-select-option>
                                                </a-select>
                                            </a-spin>
                                            <!-- <span v-if="submitModalData.headerCenterTitle && submitModalData.headerCenterTitle.indexOf('综合评定') !== -1" class="tj-blr-tips-box" >提示：请选择2个办理人</span> -->
                                        </a-form-item>
                                        <a-form-item style="margin-bottom: 15px;" v-if="submitModalData.isCyyj">
                                            <div style="display: flex;justify-content: space-between;align-items: center;">
                                                <div>
                                                    <span>常用意见：</span>
                                                    <a-button @click="selecToftenUse('同意')" size="small" style="margin: 0 8px;color: #2F54EB;">同意</a-button>
                                                    <a-button @click="selecToftenUse('不同意')" size="small" style="color: #2F54EB;">不同意</a-button>
                                                    <a-button @click="selecToftenUse('已阅')" size="small" style="margin: 0 8px;color: #2F54EB;">已阅</a-button>
                                                    <a-button @click="selecToftenUse()" size="small" style="color: #2F54EB;" icon="ellipsis"></a-button>
                                                </div>
                                                <a-button @click="addOpinion" size="small" icon="plus">添加到常用意见</a-button>
                                            </div>
                                            <a-textarea 
                                                v-model:value="formState.opinion"
                                                v-decorator="['opinion',{ initialValue:formState.opinion, rules: rules.opinion}]"
                                                placeholder="请输入办理意见"
                                                :autosize="{ minRows: 3, maxRows: 10000 }"
                                            ></a-textarea>
                                        </a-form-item>
                                        <a-form-item style="margin-bottom: 15px;" v-if="submitModalData.isDxtx">
                                            <span>发送短信提醒待办人：</span>
                                            <a-radio-group :options="[{label:'是',value:'是'},{label:'否',value:'否'}]" defaultValue="否" v-model="formState.smgflag"/>
                                        </a-form-item>
                                    </a-form>
                                </a-collapse-panel>
                                <a-collapse-panel id="processingConditions03" key="3" header="转办信息" v-if="submitModalData.isZbxx">
                                    <a-form ref="form" :form="form" >
                                        <span>转办科室：</span>
                                        <compSelector
                                            :key="ksflKey"
                                            v-model="formState.ksfl" 
                                            :defaultValue="formState.ksfl"
                                            compType="Select"
                                            dictionaryType="科室业务分类"
                                            placeholder="转办科室"
                                        />
                                    </a-form>
                                </a-collapse-panel>
                                <a-collapse-panel id="processingConditions04" key="4" header="下一步" v-if="submitModalData.isXyb">
                                    <a-form ref="form" :form="form" >
                                        <a-form-item>
                                            <span>下个环节：{{ submitModalData.nextNode }}</span>
                                        </a-form-item>
                                    </a-form>
                                </a-collapse-panel>
                            </a-collapse>
                        </div>
                        <a-drawer
                        title="常用意见"
                        placement="right"
                        :closable="false"
                        :visible="drawerVisible"
                        @close="drawerVisible = false"
                        :width="400"
                        >
                            <div class="processing-conditions-all-addopinions-input-search" >
                                <a-input-search
                                    :key="inputSearchKey"
                                    placeholder="请输入内容"
                                    enter-button="搜索"
                                    size="small"
                                    @search="onSearchOpinion"
                                />
                            </div>
                            <a-list :data-source="opinionsList" :loading="loading" class="processing-conditions-all-addopinions-list">
                                <a-list-item slot="renderItem" slot-scope="item, index">
                                    <div v-if="item.isEdit" style="width: 100%;">
                                        <a-textarea 
                                            v-model="item.fcontent"
                                            :autosize="{ minRows: 1, maxRows: 15 }"
                                            @blur="editOpinionBlur(item,index,item.fcontent)"
                                            placeholder="请输入内容"
                                        ></a-textarea>
                                    </div>
                                    <div v-else >{{ item.fcontent }}</div>
                                    <div slot="actions">
                                        <div>
                                            <a-icon style="padding-right: 15px;font-size: 16px;color: #5ca3e5;" v-if="!item.isEdit" @click="editOpinion(item,index)" type="edit" />
                                            <a-icon style="font-size: 16px;color: #ed5565;" @click="deleteOpinion(item)" type="delete" />
                                        </div>
                                        <a-button @click="selelctOptitonText(item.fcontent)" class="blue-btn" type="primary" icon="select" >使用</a-button>
                                    </div>
                                </a-list-item>
                            </a-list>
                        </a-drawer>
                    </div>
                    <div>
                        <div style="background: #fff;margin: 0px 5px 20px 20px;height: 200px;position: absolute;top: -10px;right: 12px;">
                            <div v-if="rapidPositioning" style="width: 125px;">
                                <div @click="rapidPositioning = false" style="color: #2F54EB;padding: 11px 7px 11px 20px;display: flex;align-items: center;justify-content: space-between;">
                                    <span>快速定位</span>
                                    <a-icon type="double-right" />
                                </div>
                                <a-anchor :affix="false" :getContainer="getContainerBox">
                                    <a-anchor-link href="#processingConditions01" title="办理记录" />
                                    <a-anchor-link href="#processingConditions02" title="办理意见" v-if="submitModalData.isBlyj"/>
                                    <a-anchor-link href="#processingConditions03" title="转办信息" v-if="submitModalData.isZbxx"/>
                                    <a-anchor-link href="#processingConditions04" title="下一步" v-if="submitModalData.isXyb"/>
                                </a-anchor>
                            </div>
                            <div v-else style="color: #2F54EB;" @click="rapidPositioning = true"><a-icon type="double-left" /></div>
                        </div>
                    </div>
                </div>
                <personnelList ref="personnelListRef" @checkPersonnel="checkPersonnel" :modaObj="{place:'',oldId:formState.internalTransferId?formState.internalTransferId.split(','):[]}" />
            </a-spin>
            <template slot="footer">
                <div>
                    <a-button v-if="submitModalData.isCancelBtn" @click="handleCancel" style="margin-right: 10px;">{{submitModalData.cancelText}}</a-button>
                    <a-button @click="handleOk" :type="submitModalData.okType">{{submitModalData.okText}}</a-button>
                </div>
            </template>
        </a-modal>
    </div>
</template>
<script>
import assessCheckApi from './service/api'
import {
    handlingOpinionsListServe,
    deleteBatchIdeaServe,
    addBatchIdeaServe,
    queryAllYbJob,
    returnUpperScSpFlowJob,
    returnUpperXcjcFlowJob,
    submitFlow,
    innerChangeFlowJob,
    queryYwbmjbrList,
    spbzlcSubmitFlow,
    zjhsSubmitFlow,
    zjhsReturnHsHsFlow,
    spbzlcReturnSpBzFlow,
    jsscbglcSubmitFlow,
    jsscbglcReturnSpBzFlow,
    spzgqrlcSubmitFlow,
    spzgqrlcReturnZgqrFlow,
    saveYwbmjbr,
    spcysaveFlow,
    spcysubmitFlow,
    spcyreturnUpperFlowJob,
    spcyqueryAllYbJob,
    spcytransferFlowJob,
    spcysubmitFlowByZwfw,
    sysUserCyyjedit,
    sjxdsubmitFlow,
    xzxkApisaveYwbmjbr,
    sjxdreturnFlowJob,
    xzxkApiqueryYwbmjbrList,
} from './service/index'
import compSelector from '@/components/compSelector/compSelector'
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
import personnelList from '../../views/administrativeOffice-new/modal/personnelList.vue'
export default {
    components:{
        commpVxeTable,
        compSelector,
        personnelList,
    },
    props:{
        processingData:{
            type:Object,
            default:{},
            required:false,
        }
    },
    computed: {
        reviewProcessData(){
            
            return this.$store.state.permission.reviewProcessData
        },
    },
    watch:{
        // processingData: {
        //     handler (newval, oldVal) {
        //         //console.log('真的获取不到吗？',newval)
        //         //console.log(this.formState)
        //         //console.log(this.internalOpinionsConfig)
        //         this.$nextTick(()=>{
        //             //console.log(this.internalOpinionsConfig)
        //             this.getData(newval)
        //         })
                
        //     },
        //     immediate: true,
        //     deep: true
        // },
    },
    data(){
        return{
            form: this.$form.createForm(this, { name: 'processingConditionsFromName' }),
            rules:{
                dbrid: [{
                    type:'array',
                    required: true,
                    message: '请选择办理人',
                    trigger: 'blur',
                }],
                opinion: [{
                    required: true,
                    message: '请输入办理意见',
                    trigger: 'blur',
                }],
                internalTransferName: [{
                    required: true,
                    message: '当前暂无办理人，请先选择办理人',
                    trigger: 'blur',
                }],
                shjid: [{
                    required: true,
                    message: '请选择退回环节',
                    trigger: 'blur',
                }],
                jbrid:[{
                    required: true,
                    message: '请选择业务部门经办人',
                    trigger: 'blur',
                }],
                // fxzspysrid: [{
                //     required: true,
                //     message: '请选择部门经办人',
                //     trigger: 'blur',
                // }],
            },
            interfaceList:{
                //旧
                returnUpperScSpFlowJob:returnUpperScSpFlowJob,//医疗器械 - 化妆品-药品注册-退回
                returnUpperXcjcFlowJob:returnUpperXcjcFlowJob,//药品生产 - 药品流通-退回
                submitFlow:submitFlow,//提交
                innerChangeFlowJob:innerChangeFlowJob,//转办
                spbzlcSubmitFlow:spbzlcSubmitFlow,
                zjhsSubmitFlow:zjhsSubmitFlow,
                zjhsReturnHsHsFlow:zjhsReturnHsHsFlow,
                spbzlcReturnSpBzFlow:spbzlcReturnSpBzFlow,
                jsscbglcSubmitFlow:jsscbglcSubmitFlow,
                jsscbglcReturnSpBzFlow:jsscbglcReturnSpBzFlow,
                spzgqrlcSubmitFlow:spzgqrlcSubmitFlow,
                spzgqrlcReturnZgqrFlow:spzgqrlcReturnZgqrFlow,

                //新
                spcysaveFlow:spcysaveFlow,
                spcysubmitFlow:spcysubmitFlow,
                spcyreturnUpperFlowJob:spcyreturnUpperFlowJob,
                spcytransferFlowJob:spcytransferFlowJob,
                spcysubmitFlowByZwfw:spcysubmitFlowByZwfw,
                sjxdsubmitFlow:sjxdsubmitFlow,//提交数据修订
                sjxdreturnFlowJob:sjxdreturnFlowJob,//数据修订退回
            },
            inputSearchKey:null,
            confirmLoading:false,
            formState:{},
            processingConditionsVisible:false,
            processingConditionsKey:null,
            ksflKey:null,
            drawerVisible:false,
            submitActiveKey:['1','2','3','4','5'],
            submitModalDefaultDatas:{
                headerLeftTitle:'办理',
                headerCenterTitle:'',
                closable:true,//是否显示右上角关闭按钮
                maskClosable:false,//点击蒙版是否关闭
                okText:'确认',//确定按钮文字
                okType:'primary',//确定按钮样式
                cancelText:'取消',//取消按钮文字
                isCancelBtn:true,//是否显示取消按钮
                width:720,//弹窗宽度
                cancelEventIsFalse:true,//点击取消按钮只关闭弹窗
                cancelEventIsFalseAndTrigger:false,//点击取消按钮关闭弹窗后触发事件
                cancelEventIsTrigger:false,//点击取消按钮不关闭弹窗并且触发事件（可自己通过触发的事件后使用
                //this.$refs.processingConditionsAllRef.processingConditionsVisible = false 关闭弹窗）
                okEventIsFalse:false,//点击确定按钮只关闭弹窗
                okEventIsFalseAndTrigger:false,//点击确认按钮关闭弹窗后触发事件
                okEventIsTrigger:true,//点击确认按钮不关闭弹窗并且触发事件（可自己通过触发的事件使用
                //this.$refs.processingConditionsAllRef.processingConditionsVisible = false 关闭弹窗）

                isBlyj:true,//办理意见
                isBlr:true,//办理人
                isThhj:false,//退回环节
                isCyyj:true,//常用意见
                isDxtx:true,//短信提醒
                isZbxx:false,//转办信息
                isXyb:true,//下一步
                isDepJbr:false,//部门经办人（目前只有移送确认用到）
                isCloseLinkPages:true,//是否关闭办理页面
                opinionType:'办理意见',
                otherData:{},
                isAskAbout:false,//询问是否提交
            },
            submitModalData:{},
            rapidPositioning:true,
            internalOpinionsKey:null,
            internalOpinionsConfig:{
                api:assessCheckApi.querySqsxDetailsById,
                rowId: 'id',
                // height:400,
                autoHidden:true,
                pageSize:10000,
                listData:'jobHistoryList',
                paramet:{}
            },
            internalOpinionsColumnsVxe:[{
                title: '环节名称',
                field: 'fhjmc',
                width:112,
            },{
                title: '待办人',
                field: 'fdbr',
            },{
                title: '办理人',
                field: 'fblr',
                width:70,
                slots: {
                    default:'fblr_default',
                }
            },{
                title: '发送时间',
                field: 'ffssj',
                width:165,
            },{
                title: '办理时间',
                field: 'fblsj',
                width:165,
            },{
                title: '使用工日',
                field: 'fsyts',
                width:86,
            },{
                title: '办理状态',
                field: 'fblzt',
                width:86,
            },{
                title: '办理意见',
                field: 'fblyj',
            }],
            segmentData:{},
            opinionsList:[],
            loading:false,
            fthyjOptions:[],
            depHandledList:[],
            depHandledKey:null,
            spinTip:'正在办理中...',
            spinning:false,
            depManagerSpinning:false,
            departmentManagerList:[],
        }
    },
    mounted(){
        this.submitModalData = JSON.parse(JSON.stringify(this.submitModalDefaultDatas))
    },
    updated(){
        //console.log(this.internalOpinionsConfig)
    },
    methods:{
        popupScroll(){
            
        },
        handleChange(val){
            //console.log(val)
            saveYwbmjbr({sqsxid:this.submitModalData.sqsxid,jbrid:val}).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        getData(val){
            if(val.isYwbmjbr){
                this.departmentManagerList = []
                this.depManagerSpinning = true
                xzxkApiqueryYwbmjbrList({sqsxid:val.sqsxid}).then(res=>{
                    if(res.code == 200){
                        this.departmentManagerList = res.result
                    }
                    this.depManagerSpinning = false
                })
            }
            this.spinning = false
            let submitModalDefaultDatas={
                headerLeftTitle:'办理',
                headerCenterTitle:'',
                closable:true,//是否显示右上角关闭按钮
                maskClosable:true,//点击蒙版是否关闭
                okText:'确认',//确定按钮文字
                okType:'primary',//确定按钮样式
                cancelText:'取消',//取消按钮文字
                isCancelBtn:true,//是否显示取消按钮
                width:720,//弹窗宽度
                cancelEventIsFalse:true,//点击取消按钮只关闭弹窗
                cancelEventIsFalseAndTrigger:false,//点击取消按钮关闭弹窗后触发事件
                cancelEventIsTrigger:false,//点击取消按钮不关闭弹窗并且触发事件（可自己通过触发的事件后使用
                //this.$refs.processingConditionsAllRef.processingConditionsVisible = false 关闭弹窗）
                okEventIsFalse:false,//点击确定按钮只关闭弹窗
                okEventIsFalseAndTrigger:false,//点击确认按钮关闭弹窗后触发事件
                okEventIsTrigger:true,//点击确认按钮不关闭弹窗并且触发事件（可自己通过触发的事件使用
                //this.$refs.processingConditionsAllRef.processingConditionsVisible = false 关闭弹窗）

                isBlyj:true,//办理意见
                isBlr:true,//办理人
                isThhj:false,//退回环节
                isCyyj:true,//常用意见
                isDxtx:true,//短信提醒
                isZbxx:false,//转办信息
                isXyb:true,//下一步
                isDepJbr:false,//部门经办人（目前只有移送确认用到）
                isCloseLinkPages:true,//是否关闭办理页面
                opinionType:'办理意见',
                otherData:{},
                isAskAbout:false,//询问是否提交
            }
            this.internalOpinionsConfig = {
                api:val.isNew?assessCheckApi.spcyquerySqsxDetailsById:assessCheckApi.querySqsxDetailsById,
                rowId: 'id',
                // height:400,
                autoHidden:true,
                pageSize:10000,
                listData:'jobHistoryList',
                paramet:{}
            }
            if(val.isXrmr){
                this.formState = {
                    internalTransferName:val.internalTransferName,
                    internalTransferId:val.internalTransferId,
                }
                
            }else{
                this.formState = {}
            }
            
            //console.log('正在办理的弹窗中',val)
            let submitModalData = JSON.parse(JSON.stringify(submitModalDefaultDatas))
            this.submitModalData = {...submitModalData,...val}
            //console.log(this.submitModalData)
            //console.log(this.internalOpinionsConfig)
            if(this.submitModalData.recordApi){
                this.internalOpinionsConfig['api'] = assessCheckApi[this.submitModalData.recordApi]
            }else{
                this.internalOpinionsConfig['api'] = val.isNew?assessCheckApi.spcyquerySqsxDetailsById:assessCheckApi.querySqsxDetailsById
            }
            if( this.submitModalData.recordApi == 'sjxdqueryJobHistoryList'){
                this.internalOpinionsConfig.listData = ''
            }
            this.internalOpinionsConfig['paramet'] = { sqsxid:val.sqsxid,jobid:val.jobid,id:val.id }
            this.internalOpinionsKey = Date.now()
            // this.formState.dbrid = Array.isArray(val.nextNodeDbrList) && val.nextNodeDbrList.length?[val.nextNodeDbrList[0].dbrid || val.nextNodeDbrList[0].value]:[]//选择框默认有办理人
            this.formState.dbrid = []
            this.getOpinionList(this.submitModalData)
            this.getReturnProcessList(this.submitModalData)
            this.processingConditionsKey = Date.now()
            this.formState.ksfl = ''
            this.ksflKey = Date.now()
            this.depHandledList = []
            if(val.isDepJbr){
                queryYwbmjbrList({sqsxid:val.sqsxid}).then(res=>{
                    if(res.code == 200){
                        if(res.result.length){
                            res.result.forEach((item,index)=>{
                                this.depHandledList.push({label:item.deptName+'/'+item.name,value:item.id,})
                            })
                            // this.formState.fxzspysrid = res.result[0].id
                            // this.form.setFieldsValue({
                            //     fxzspysrid:res.result[0].id,
                            // });
                            this.depHandledKey = Date.now()
                        }else{
                            this.depHandledList = []
                            // this.form.setFieldsValue({
                            //     fxzspysrid:[],
                            // });
                            this.formState.fxzspysrid = []
                            this.depHandledKey = Date.now()
                        }
                    }else{
                        this.$message.warning(res.message)
                    }
                })
            }
            //console.log(this.depHandledList)
            
        },
        //选择转办办理人
        selectInternalTransfer(){
            this.$refs.personnelListRef.personnelListVisible = true
            this.$refs.personnelListRef.getData({place:'',oldId:this.formState.internalTransferId?this.formState.internalTransferId.split(','):[]})
        },
        selecToftenUse(val){
            if(val){
                this.form.setFieldsValue({
                    opinion:val,
                });
                this.formState.opinion = val
            }else{
                this.inputSearchKey = Date.now()
                this.drawerVisible = true
                this.getOpinionList(this.submitModalData)
                
            }
        },
        getReturnProcessList(val){
            this.fthyjOptions = []
            if(this.submitModalData.isNew){
                spcyqueryAllYbJob({jobid:val.jobid}).then(res=>{
                    if(res.code == 200){
                        res.result.forEach(item=>{
                            this.fthyjOptions.push({value:item.id,label:item.fhjmc})
                        })
                        if(res.result.length){
                            this.formState.shjid = res.result[0].id
                        }
                        
                    }
                })
            }else{
                queryAllYbJob({jobid:val.jobid}).then(res=>{
                    if(res.code == 200){
                        res.result.forEach(item=>{
                            this.fthyjOptions.push({value:item.id,label:item.fhjmc})
                        })
                        if(res.result.length){
                            this.formState.shjid = res.result[0].id
                        }
                        
                    }
                })
            }
        },
        
        onSearchOpinion(val){
            //console.log('搜索内容',val)
            this.getOpinionList(this.submitModalData,val)
        },
        getOpinionList(val,content){
            this.loading = true
            let data = {}
            if(content){
                data = {ftype1:val.opinionType,pageNo:1,pageSize:100000,fcontent:content}
            }else{
                data = {ftype1:val.opinionType,pageNo:1,pageSize:100000}
            }
            handlingOpinionsListServe(data).then(res=>{
                if(res.code == 200){
                    this.opinionsList = res.result.records
                }
                this.loading = false
            })
        },
        addOpinion(){
            if(this.formState.opinion){
                addBatchIdeaServe({ftype1:this.submitModalData.opinionType,fcontent:this.formState.opinion}).then(res=>{
                    if(res.code == 200){
                        this.$message.success(res.message)
                    }else{
                        this.$message.warning(res.message)
                    }
                })
            }else{
                this.$message.warning('当前输入框无内容')
            }
        },
        deleteOpinion(val){
            deleteBatchIdeaServe({ids:val.id}).then(res=>{
                if(res.code == 200){
                    this.getOpinionList(this.submitModalData)
                    this.$message.success(res.message)
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        editOpinion(item,index){
            this.opinionsList.splice(index,1,{
                ...item,
                isEdit:true,
            })
            this.$nextTick(() => {
                window.dispatchEvent(new Event('resize'));
            });
        },
        editOpinionBlur(item,index,val){
            sysUserCyyjedit({id:item.id,fcontent:val}).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.opinionsList.splice(index,1,{
                        ...item,
                        isEdit:false,
                    })
                    this.$nextTick(() => {
                        window.dispatchEvent(new Event('resize'));
                    });
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        selelctOptitonText(val){
            this.formState.opinion = val
            this.form.setFieldsValue({
                opinion:val
            });
            this.drawerVisible = false
        },
        handleCancel(){//取消事件 -- 默认点击取消按钮只关闭弹窗
            // 
            if(this.submitModalData.cancelEventIsFalse){//点击取消按钮只关闭弹窗 -- 当前为默认
                this.processingConditionsVisible = false
            }else if(this.submitModalData.cancelEventIsFalseAndTrigger){//点击取消按钮关闭弹窗后触发事件
                this.processingConditionsVisible = false
                //这里写触发的事件 ------- 还没写哦
            }else if(this.submitModalData.cancelEventIsTrigger){//点击取消按钮不关闭弹窗并且触发事件
                //（可自己通过触发的事件后使用this.$refs.processingConditionsAllRef.processingConditionsVisible = false 关闭弹窗）
                //这里写触发的事件 ------- 还没写哦
            }
        },
        checkPersonnel(val,list,list2){
            //console.log(val,list,list2)
            this.formState.internalTransferId = list.length?list.join(','):''
            this.formState.internalTransferName = list2.length?list2.join(','):''
            this.form.setFieldsValue({
                internalTransferName:list2.length?list2.join(','):''
            });
        },
        async handleOk(){//确定事件 -- 默认点击确定按钮不关闭弹窗并且触发事件
            //console.log(this.submitModalData)
            let valuesJbrid = ''
            if(this.submitModalData.okEventIsFalse){//点击确定按钮只关闭弹窗
                this.processingConditionsVisible = false
            }else if(this.submitModalData.okEventIsFalseAndTrigger){//点击确认按钮关闭弹窗后触发事件
                this.processingConditionsVisible = false
                //这里写触发的事件 ------- 还没写哦
            }else if(this.submitModalData.okEventIsTrigger){//点击确认按钮不关闭弹窗并且触发事件 -- 当前为默认
                //（可自己通过触发的事件后使用this.$refs.processingConditionsAllRef.processingConditionsVisible = false 关闭弹窗）
                //这里写触发的事件 ------- 还没写哦
                let data = {}//需要传的参数
                let isSubmit = false
                if(this.submitModalData.interface == 'returnUpperScSpFlowJob' || 
                this.submitModalData.interface == 'zjhsReturnHsHsFlow' || 
                this.submitModalData.interface == 'spbzlcReturnSpBzFlow' ){////医疗器械 - 化妆品-药品注册-退回
                    this.form.validateFields((err, values) => {
                        if(!err){
                            valuesJbrid = values.jbrid
                            data = {
                                jobid:this.submitModalData.jobid,
                                opinion:values.opinion?values.opinion:'',
                                shjid:values.shjid?values.shjid:'',
                                ...this.submitModalData.otherData,
                            }
                            isSubmit = true
                        }
                    })
                }else if(this.submitModalData.interface == 'returnUpperXcjcFlowJob' 
                || this.submitModalData.interface == 'jsscbglcSubmitFlow' 
                || this.submitModalData.interface == 'spzgqrlcReturnZgqrFlow'
                || this.submitModalData.interface == 'spcyreturnUpperFlowJob'
                || this.submitModalData.interface == 'sjxdreturnFlowJob'
                ){////药品生产 - 药品流通-退回
                    this.form.validateFields((err, values) => {
                        if(!err){
                            valuesJbrid = values.jbrid
                            data = {
                                jobid:this.submitModalData.jobid,
                                opinion:values.opinion?values.opinion:'',
                                shjid:values.shjid?values.shjid:'',
                                ...this.submitModalData.otherData,
                            }
                            isSubmit = true
                        }
                    })
                }else if(this.submitModalData.interface == 'submitFlow'
                 ||  this.submitModalData.interface == 'spbzlcSubmitFlow'
                 || this.submitModalData.interface == 'zjhsSubmitFlow' 
                 || this.submitModalData.interface == 'jsscbglcReturnSpBzFlow' 
                 || this.submitModalData.interface == 'spzgqrlcSubmitFlow'
                 || this.submitModalData.interface == 'spcysubmitFlow'
                 || this.submitModalData.interface == 'sjxdsubmitFlow'
                 ){//提交
                    this.form.validateFields((err, values) => {
                        if(!err){
                            valuesJbrid = values.jbrid
                            data = {
                                jobid:this.submitModalData.jobid,
                                sqsxid:this.submitModalData.sqsxid,
                                dbrid:this.submitModalData.isXrmr?this.formState.internalTransferId:values.dbrid?values.dbrid.join(','):'',
                                opinion:values.opinion?values.opinion:'',
                                smgflag:this.formState.smgflag,
                                ...this.submitModalData.otherData,
                                map:this.submitModalData.map?this.submitModalData.map:{}
                            }
                            isSubmit = true
                        }else{
                            //console.log(err)
                        }
                    })
                }else if(this.submitModalData.interface == 'innerChangeFlowJob'){//转办
                    if(this.formState.ksfl){
                        data = {
                            jobid:this.submitModalData.jobid,
                            ksfl:this.formState.ksfl,
                            ...this.submitModalData.otherData,
                        }
                        isSubmit = true
                    }else{
                        this.$message.warning('请选择转办科室')
                    }
                    
                }else if(this.submitModalData.interface == 'spcytransferFlowJob'){//内部转办
                    this.form.validateFields(['internalTransferName','opinion'], { force: true }, (err, values)=> {
                        if(!err){
                            data = {
                                jobid:this.submitModalData.jobid,
                                opinion:values.opinion?values.opinion:'',
                                dbrid:this.formState.internalTransferId,
                                smgflag:this.formState.smgflag,
                                ...this.submitModalData.otherData,
                            }
                            isSubmit = true
                        }
                    
                    })
                }
                if(isSubmit){
                    this.spinning = true
                    this.confirmLoading = true
                    
                    if(this.submitModalData.isYwbmjbr){
                        let ywbmRes = {}
                            ywbmRes = await xzxkApisaveYwbmjbr({jbrid:valuesJbrid,sqsxid:this.submitModalData.sqsxid})
                            //console.log(ywbmRes)
                            if(ywbmRes.code !== 200){
                                this.$message.warning(ywbmRes.message)
                                this.spinning = false
                                this.confirmLoading = false
                                return false
                            }
                        
                    }
                    if(this.submitModalData.isAskAbout){
                        let that = this
                        this.$confirm({
                            title:'确认提交吗？',
                            onOk() {
                                that.interfaceList[that.submitModalData.interface](data).then(res=>{
                                    if(res.code == 200){
                                        that.$message.success(res.message)
                                        that.$emit('interfaceSuccessful',!that.submitModalData.isCloseLinkPages)
                                        this.spinning = false
                                        this.confirmLoading = false
                                        that.processingConditionsVisible = false
                                    }else{
                                        this.spinning = false
                                        this.confirmLoading = false
                                        that.$message.warning(res.message)
                                    }
                                })
                            }
                        })
                    }else{
                        await this.interfaceList[this.submitModalData.interface](data).then(res=>{
                            if(res.code == 200){
                                this.$message.success(res.message)
                                this.$emit('interfaceSuccessful',!this.submitModalData.isCloseLinkPages)
                                this.spinning = false
                                this.confirmLoading = false
                                this.processingConditionsVisible = false
                            }else{
                                this.spinning = false
                                this.confirmLoading = false
                                this.$message.warning(res.message)
                            }
                        })
                    }
                    
                }
                
            }
        },
        getContainerBox() {
            return this.$refs.containerBox
        },
    }
}
</script>
<style lang="less" scoped>
.modal-header-left-title{
    margin: 0;
    // color: rgba(0,0,0,.85);
    font-weight: 600;
    font-size: 24px;
    line-height: 22px;
    word-wrap: break-word;
    font-family: kaiTi !important;
}
.modal-header-conter-title{
    flex: 1;
    text-align: center;
    font-size: 1.17em;
    // color: rgba(0, 0, 0, 0.85);
    font-weight: 500;
    font-family: kaiTi !important;
}
.processing-conditions-content{
    // display: flex;
    .left-content{
        height: calc(100vh - 200px);
        overflow-y: auto;
    }
    .ant-form-item{
        margin-bottom: 3px;
    }
    .ant-radio-group{
        display: inline-block !important;
    }
}

</style>
<style lang="less">
    .processing-conditions-option-modal{
        .ant-modal-body{
            padding: 8px;
        }
        .ant-modal-header{
            color: #fff !important;
        }
        .ant-drawer-content-wrapper{
            width: 300px !important;
        }
        .tj-blr-tips-box{
            color: #ed5565;
            padding-left: 15px;
            font-weight: 600;
        }
    }
    .processing-conditions-all-addopinions-list{
        .ant-list-item-action{
            margin-left: 15px !important;
        }
    }
    .processing-conditions-all-addopinions-input-search{
        .ant-input-sm{
            height: 30px !important;
        }
    }

</style>